package co.com.javeriana.aes.touresbalon.webserviceclients;

import co.com.javeriana.aes.touresbalon.webserviceclients.dto.ProductDTO;
import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
import java.util.GregorianCalendar;

/**
 *
 * @author Jonathan Fernandez <jonathan.fvargas@gmail.com>
 */
public class ProductsClient {

    public static Integer addProduct(ProductDTO dto) {

        java.lang.Integer result = null;

        try {

            // Call Web Service Operation
            org.tempuri.OperationProducts service = new org.tempuri.OperationProducts();
            org.tempuri.IProducts port = service.getBasicHttpBindingIProducts();
            // TODO initialize WS operation arguments here
            org.datacontract.schemas._2004._07.b2c_core.Product product = new org.datacontract.schemas._2004._07.b2c_core.Product();

            //product.setDepartureOut(new XMLGregorianCalendarImpl(new GregorianCalendar()));
            product.setDescription(dto.getDescription());
            //product.setEntryDate(new XMLGregorianCalendarImpl(new GregorianCalendar()));
            product.setIdCity(dto.getCityId());
            product.setIdFeeHotel(dto.getFeeHotel());
            product.setIdFeeShow(dto.getFeeShow());
            product.setIdFeeTransport(dto.getFeeTtransport());
            product.setUrl("url");
            product.setShowDate(new XMLGregorianCalendarImpl(new GregorianCalendar()));
            product.setShow(dto.getName());

            //product.setImage( new String ("holaa").getBytes() );
            product.setImage(dto.getImage());

            /*product.setCity(null);
             product.setFeeHotel(new FeeHotel());
             product.setFeeShow(new FeeShow());
             product.setFeeTransport(new FeeTransport());
             */
            // TODO process result here
            result = port.createProduct(product);

            System.out.println("Result = " + result);

        } catch (Exception ex) {

            ex.printStackTrace();

        }

        return result;

        // TODO handle custom exceptions here
    }

    public static void main(String args[]) {

       // addProduct();

    }

}
